I have the following code for which I am trying to convert input entered by a user to replace certain characters (e with a 3 and t with a 7) but instead, I am getting a [object HTMLInputElement] error in my output.
function ReplaceChars() {
var json = JSON.parse(localStorage.getItem("registration"));
var characters = json['charsEntered'];
var percentage = "";
var total = "";
result = characters
.replaceAll(/e|E/g, "3")
.replaceAll(/t|T/g, "7")
total = characters.length;
if (result.match(/e|E|t|T/g) == null) {
roundedPercentage = 0.00;
result = charsEntered;
} else {
percentage = ((characters.match(/e|E|t|T/g).length) / total) * 100
roundedPercentage = percentage.toFixed(2);
}
console.log(result);
$("#charsConverted").val(result);
$("#percentage").val(roundedPercentage + "%");
}